#ifndef REGISTEREDDIALOG_H
#define REGISTEREDDIALOG_H

#include <QDialog>
#include <QTimer>
#include "global.h"



namespace Ui {
class registeredDialog;
}

class registeredDialog : public QDialog
{
    Q_OBJECT

public:
    explicit registeredDialog(QWidget *parent = nullptr);
    ~registeredDialog();


private slots:
    void on_verify_button_clicked();
    void slot_reg_mod_finish(ReqId id, QString res, ErrorCodes err);
    void on_yes_button_clicked();

    void on_returnButton_clicked();

    void on_no_button_clicked();

private:
    void initHttpHandlers();
    Ui::registeredDialog *ui;
    void showTip(QString,bool b_ok);
    //根据请求id调用相应的处理函数。
    QMap<ReqId,std::function<void(const QJsonObject)>> _handlers;
    //存储输入框规则验证时的错误
    QMap<TipErr, QString> _tip_errs;
    void AddTipErr(TipErr te, QString tips);
    void DelTipErr(TipErr te);
    void ChangeTipPage();
    bool checkUserValid();
    bool checkPassValid();
    bool checkEmailValid();
    bool checkVarifyValid();
    bool checkConfirmValid();
    QTimer *_countdown_timer;
    int _countdown;
signals:
    void sigSwitchLogin();
};

#endif // RegisteredDialog_H
